package com.itheima.config;

import com.itheima.common.utils.SMSUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SMSConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public SMSUtils smsUtils(SMSProperties smsProperties) {
        return new SMSUtils(smsProperties.getAccessKeyId(),
                smsProperties.getAccessKeySecret(),
                smsProperties.getSignName(),
                smsProperties.getTemplateCode(),
                smsProperties.getEndpoint());

    }
}
